﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")"></script>
            
<div class="large-12">
<fieldset class="large-12">
    <legend>Create App</legend>
   <!-- @Html.Label("App Type")
    @Html.RadioButton("Iframe", true, new { id="RadioIA", onclick="javascript:Radio('Iframe');"}) Iframe 
    @Html.RadioButton("Caja",true, new { id = "RadioCA", onclick="javascript:Radio('Caja');" }) Caja 
    @using (Html.BeginForm("Iframe", "CreateApp", FormMethod.Post, new { id = "type", enctype = "multipart/form-data" }))
    {
        @Html.ValidationSummary(true)
        <div id="AppType">

        </div>
        
        <p>
            <input id="sub" type="submit" class="button" value="Create"/>
        </p>
    } -->
    <div class="section-container auto" data-section data-options="deep_linking: true; one_up: false">
              <section>
                <p class="title" data-section-title><a href="#Canvas">Canvas</a></p>
                <div class="content" data-slug="panel1" data-section-content>
                    @using (Html.BeginForm("Iframe", "CreateApp", FormMethod.Post, new { id = "type", enctype = "multipart/form-data" }))
                    {
                        @Html.ValidationSummary(true)
                        <div id="AppType">
                            @{Html.RenderPartial("CanvasApp");}
                        </div>
        
                        <p>
                            <input type="submit" class="button" value="Create"/>
                        </p>
                    }
                </div>
              </section>
              <div data-section-region class="section">
                <p class="title" data-section-title><a href="#Caja">Caja</a></p>
                <div class="content" data-slug="panel1" data-section-content>
                    @using (Html.BeginForm("Caja", "CreateApp", FormMethod.Post, new { id = "type", enctype = "multipart/form-data" }))
                    {
                        @Html.ValidationSummary(true)
                        <div id="AppType">
                            @{Html.RenderPartial("CajaApp",new MVC_basic.ViewModels.CajaAppViewModel());}
                        </div>
        
                        <p>
                            <input type="submit" class="button" value="Create"/>
                        </p>
                    }
                </div>
              </div>
            </div>
</fieldset>
</div>


<script type="text/javascript">
    $('#sub').hide();
    function Radio(type) {
        $('#sub').show();
        if (type == "Iframe") {
            $('#RadioCA').prop('checked', false);
            $.ajax({
                url: "CreateApp/CanvasApp",
                type: "get",
                success: function (data) {
                    $('#AppType').html(data);
                    $('#type').attr('action', 'CreateApp/Iframe');
                },
                error: function () {
                    alert("error");
                }
            });
        }
        else if (type == "Caja") {
            $('#RadioIA').prop('checked', false);
            $.ajax({
                url: "CreateApp/CajaApp",
                type: "get",
                success: function (data) {
                    $('#AppType').html(data);
                    $('#type').attr('action', 'CreateApp/Caja');
                },
                error: function () {
                    alert("error");
                }
            });
        }
    }
</script>